#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 1e5 + 10;

int n, m;
vector<int> v[N];

int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    for(int i = 1; i <= m; i ++){
        int a, b;
        cin >> a >> b;
        v[a].push_back(b), v[b].push_back(a);
    }

    for(int i = 1; i <= n; i ++) sort(v[i].begin(), v[i].end());

    for(int i = 1; i <= n; i ++){
        cout << v[i].size() << " ";
        for(int j = 0; j < v[i].size(); j ++) cout << v[i][j] << " ";
        cout << '\n';
    }


    return 0;
}